package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentSaveDto1;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**实现评论新增,列表展示,评论点赞接口
 * @author lzq
 * @data 2023/5/16 14:59
 */
@RestController
@RequestMapping("/api/v1/comment")
@Slf4j
public class CommentController {

    @Autowired
    private CommentService commentService;
    /**
     * 评论保存
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveByContent(@RequestBody CommentSaveDto1 dto){
      return   commentService.saveByContent(dto);
    }

    /**
     * 评论点赞
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
      return  commentService.like(dto);
    }

    /**
     * 展示评论列表
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDto dto){
        return  commentService.load(dto);
    }
}
